﻿using Circle.Web.Application.Api;
using Circle.Web.Drivers.Contract;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Circle.Web.Controllers.Api
{
    public class UserController : BaseApiController
    {
        private ITopicDriver _topicDriver;
        private ICommentDriver _commentDriver;

        public UserController()
        {
            
        }

        [System.Web.Http.HttpGet]
        public string Topic(int? pageIndex)
        {
            _topicDriver = DependencyResolver.Current.GetService<ITopicDriver>();
            int pIndex = pageIndex.HasValue && pageIndex.Value > 0 ? pageIndex.Value : 0;
            var pageTopics = _topicDriver.PagingMyClientTopics(pIndex, DefaultSetting.TopicsPerPage, "CreateTime DESC");
            return pageTopics.ToJson();
        }

        [System.Web.Http.HttpGet]
        public string Comment(int? pageIndex)
        {
            _commentDriver  = DependencyResolver.Current.GetService<ICommentDriver>();
            int pIndex = pageIndex.HasValue && pageIndex.Value > 0 ? pageIndex.Value : 0;
            var pageComments = _commentDriver.PagingMyClientComments(pIndex, DefaultSetting.CommentsPerPage, "CreateTime DESC");
            return pageComments.ToJson();
        }

    }
}
